package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.LitemallBrandQualificationMapper;
import org.linlinjava.litemall.db.domain.LitemallBrandQualification;
import org.linlinjava.litemall.db.domain.LitemallBrandQualificationExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LitemallBrandQualificationService {
    @Resource
    LitemallBrandQualificationMapper brandQualificationMapper;
    public void add(LitemallBrandQualification brandPeople) {
        brandQualificationMapper.insertSelective(brandPeople);
    }

    public LitemallBrandQualification findById(Integer id) {
        return brandQualificationMapper.selectByPrimaryKey(id);
    }

    public void deleteById(Integer id) {
        brandQualificationMapper.deleteByPrimaryKey(id);
    }

    public int updateById(LitemallBrandQualification brandQualification) {
        return brandQualificationMapper.updateByPrimaryKeySelective(brandQualification);
    }

    public void deleteByBrandId(Integer id) {
        LitemallBrandQualificationExample example = new LitemallBrandQualificationExample();
        example.or().andBrandIdEqualTo(id);
        brandQualificationMapper.deleteByExample(example);
    }

    public List<LitemallBrandQualification> findByBrandId(Integer id) {
        LitemallBrandQualificationExample example = new LitemallBrandQualificationExample();
        example.or().andBrandIdEqualTo(id);
        return brandQualificationMapper.selectByExample(example);

    }

    public List<LitemallBrandQualification> findByQIdAndBrandId(Integer integer, Integer id) {
        LitemallBrandQualificationExample example = new LitemallBrandQualificationExample();
        example.or().andBrandIdEqualTo(id).andQualificationIdEqualTo(integer);
        return brandQualificationMapper.selectByExample(example);
    }

    public List<LitemallBrandQualification> findByBrandIdAndHas(Integer id) {
        LitemallBrandQualificationExample example = new LitemallBrandQualificationExample();
        example.or().andBrandIdEqualTo(id).andIsHasEqualTo(1);
        return brandQualificationMapper.selectByExampleWithBLOBs(example);
    }
}
